<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('职位管理')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <input type="hidden" name="positionId" th:value="${positionId}"/>
                        <ul>

                            <li>
                                <p>姓名：</p>
                                <input type="text" name="userName"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var statusDatas = [[${@dict.getType('job_operate_status')}]];
        var operateResultDatas = [[${@dict.getType('job_operate_result')}]];
        var prefix = ctx + "job/position";
        var receivePrefix = ctx + "job/receive";
        $(function() {
            var options = {
                url: prefix + "/deliveryList",
                modalName: "投递情况",
                columns: [
                    {
                        field : 'resumeId',
                        title : '简历id',
                        visible: false
                    },
                    {
                        field : 'receiveId',
                        title : '接收',
                        visible: false
                    },
                {
                    field : 'userName',
                    title : '姓名'
                },
                {
                    field : 'resumeName',
                    title : '简历名称'
                },
                {
                    field : 'birthday',
                    title : '生日'
                },
                    {
                        field : 'receiveTime',
                        title : '投递时间'
                    },
                {
                    field : 'operateStatus',
                    title : '状态',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(statusDatas, value);
                    }
                },
                    {
                        field : 'operateResult',
                        title : '处理结果',
                        formatter: function(value, row, index) {
                            return $.table.selectDictLabel(operateResultDatas, value);
                        }
                    },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="operating(\'' + row.receiveId + '\', \'' + row.resumeId + '\')"><i class="fa fa-edit"></i>查看简历</a> ');
                        if (row.operateStatus == 0) {
                            actions.push('<a class="btn btn-primary btn-xs " href="javascript:void(0)" onclick="changeStatus(\'' + row.receiveId + '\')"><i class="fa fa-edit"></i>同意</a> ');
                            actions.push('<a class="btn btn-default btn-xs" href="javascript:void(0)" onclick="refuse(\'' + row.receiveId + '\')"><i class="fa fa-edit"></i>拒绝</a> ');
                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        /* 处理 */
        function operating(receiveId, resumeId) {
            var url = prefix + '/operating/' + receiveId + "/" + resumeId;
            $.modal.open("查看", url);
        }
        /* 同意 */
        function changeStatus(receiveId) {
            $.modal.confirm("确认同意该简历吗？", function() {
                $.operate.post(receivePrefix + "/changeStatus", { "receiveId": receiveId, "operateResult": 0 });
            })
        }

        /* 处理 */
        function refuse(receiveId) {
            var url = prefix + '/refuseReason/' + receiveId;
            $.modal.open("拒绝", url);
        }
    </script>
</body>
</html>